StringToDouble Function

public function StringToDouble(string, error) result(number)

Converts number string to a double precision real number Arguments: string String to be converted Result: double precision real number

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: string
logical, intent(out), optional :: error

Return Value real(kind=double)


Variables

Type Visibility Attributes Name Initial
integer(kind=short), public :: ios

Source Code

FUNCTION StringToDouble &
  ( string, error )           &
RESULT (number)

IMPLICIT NONE

! Function arguments
! Scalar arguments with intent(in):
CHARACTER(LEN = *), INTENT (IN)  :: string

!Arguments with intent (out).
LOGICAL, OPTIONAL, INTENT(OUT) :: error

! Local scalars:
REAL (KIND = double)    :: number
INTEGER (KIND = short)  :: ios 

!------------end of declaration------------------------------------------------

READ (string,*,iostat = ios) number

IF (PRESENT (error)) THEN
   error = .FALSE.
   IF ( ios /= 0 ) THEN
     error = .TRUE.
     RETURN
   END IF
ELSE
   IF ( ios /= 0 ) THEN
     CALL Catch ('error', 'StringManipulation', 'converting string to double ',&
               code = genericIOError, argument = string )
   END IF
END IF




END FUNCTION StringToDouble